<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:insert="~{common/comm_blocks :: comm_header(title=~{::title}, links=~{::link}, scripts=~{::head_scripts/script})}">
    <title>欢迎页</title>
    <th:block th:fragment="head_scripts">
        <script>
            $(function(){
                $('#p_msg').html("你好，欢迎光临！！！");
                $('#p_meta_csrf_header_name').text("Meta CSRF Header Name:" + getCsrfHeaderName());
                $('#p_meta_csrf_cookie_name').text("Meta CSRF Cookie Name:" + getCsrfCookieName());
                $('#p_cookie_csrf').text("Cookie CSRF:" + $.cookie(getCsrfCookieName()));
            });
        </script>
    </th:block>
</head>
<body>
<p id="p_msg">成功</p>

<p th:text="'【remoteUser】 : ' + ${remoteUser?:''}"></p>
<p th:text="'【principalName】 : ' + ${principalName?:''}"></p>
<p th:text="'【authorities】 : ' + ${authorities?:''}"></p>

<p th:text="'requestKey : ' + ${requestKey?:''}"></p>
<p th:text="'modelKey : ' + ${modelKey?:''}"></p>

<p th:text="'_csrf.headerName : ' + ${_csrf?.headerName?:'-'}"></p>
<p th:text="'_csrf.parameterName : ' + ${_csrf?.parameterName}?:''"></p>
<p th:text="'_csrf.token : ' + ${_csrf?.token}?:''"></p>

<p id="p_meta_csrf_header_name"></p>
<p id="p_meta_csrf_cookie_name"></p>
<p id="p_cookie_csrf"></p>

<input type="button" id="btn_get" onclick="testMethod(1)" value="Get Method"/>
<input type="button" id="btn_post" onclick="testMethod(2)"  value="Post Method"/>
<script>
    function testMethod(type){
        let method = type === 1 ? "get" : "post";
        $.ajax({
            type: method,
            url: "demo/testMethod.do",
            data:{param:"testMethod"},
            success:function(data){
                if(successData(data)){
                    $("#p_msg").html("成功："+ data.data);
                }else{
                    $("#p_msg").html("失败");
                }
            }
        });
    }

</script>
</body>
</html>